﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/SiteManager.Master" AutoEventWireup="true" CodeBehind="productmanager.aspx.cs" Inherits="NSX07.Admin.productmanager" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .style1
        {
            width: 261px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    
    <table style="width: 100%;">
        <tr>
            <td class="style1">
                Categories
            </td>
            <td>
                Products
            </td>
        </tr>
        <tr valign="top">
            <td valign="top" class="style1">
               <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" 
                    DataSourceID="SqlDataSource_Category" DataTextField="name" DataValueField="id">
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSource_Category" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                    SelectCommand="SELECT [id], [name] FROM [Category]"></asp:SqlDataSource>
                <br /><br />
                <asp:FormView ID="FormView1" runat="server" 
                    DataKeyNames="id" DataSourceID="SqlDataSource_MCategory" Width="237px">
                    <EditItemTemplate>
                        id:
                        <asp:Label ID="idLabel1" runat="server" Text='<%# Eval("id") %>' />
                        <br />
                        name:
                        <asp:TextBox ID="nameTextBox" runat="server" Text='<%# Bind("name") %>' />
                        <br />
                        imgeUrl:
                        <asp:TextBox ID="imgeUrlTextBox" runat="server" Text='<%# Bind("imgeUrl") %>' />
                        <br />
                        parent:
                        <asp:TextBox ID="parentTextBox" runat="server" Text='<%# Bind("parent") %>' />
                        <br />
                        hard_soft:
                        <asp:TextBox ID="hard_softTextBox" runat="server" 
                            Text='<%# Bind("hard_soft") %>' />
                        <br />
                        <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                            CommandName="Update" Text="Update" CssClass="prod_buy"  />
                        &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                            CausesValidation="False" CommandName="Cancel" Text="Cancel" CssClass="prod_buy"  />
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        name:
                        <asp:TextBox ID="nameTextBox" runat="server" Text='<%# Bind("name") %>' />
                        <br />
                        imgeUrl:
                        <asp:TextBox ID="imgeUrlTextBox" runat="server" Text='<%# Bind("imgeUrl") %>' />
                        <br />
                        parent:
                        <asp:TextBox ID="parentTextBox" runat="server" Text='<%# Bind("parent") %>' />
                        <br />
                        hard_soft:
                        <asp:TextBox ID="hard_softTextBox" runat="server" 
                            Text='<%# Bind("hard_soft") %>' />
                        <br />
                        <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                            CommandName="Insert" Text="Insert" CssClass="prod_buy"  />
                        &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                            CausesValidation="False" CommandName="Cancel" Text="Cancel" CssClass="prod_buy"  />
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <asp:Image ID="Image1" runat="server" Height="177px" 
                            ImageUrl='<%# Eval("imgeUrl") %>' Width="169px" />
                        
                        <br />
                        ID:
                        <asp:Label ID="nameLabel0" runat="server" Text='<%# Bind("id") %>' />
                        <br />
                        name:
                        <asp:Label ID="nameLabel" runat="server" Text='<%# Bind("name") %>' />
                        <br />
                        parent:
                        <asp:Label ID="parentLabel" runat="server" Text='<%# Bind("parent") %>' />
                        <br />
                        hard_soft:
                        <asp:Label ID="hard_softLabel" runat="server" Text='<%# Bind("hard_soft") %>' />
                        <br />
                        <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" 
                            CommandName="Edit" Text="Edit" CssClass="prod_buy"  />
            &nbsp;<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" 
                            CommandName="Delete" Text="Delete" CssClass="prod_buy"  />
                        &nbsp;<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
                            CommandName="New" Text="New" CssClass="prod_buy"  />
                    </ItemTemplate>
                </asp:FormView>
                <asp:SqlDataSource ID="SqlDataSource_MCategory" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                    DeleteCommand="DELETE FROM [Category] WHERE [id] = @id" 
                    InsertCommand="INSERT INTO [Category] ([name], [imgeUrl], [parent], [hard_soft]) VALUES (@name, @imgeUrl, @parent, @hard_soft)" SelectCommand="SELECT * FROM [Category]
            WHERE [id] = @id" 
                    UpdateCommand="UPDATE [Category] SET [name] = @name, [imgeUrl] = @imgeUrl, [parent] = @parent, [hard_soft] = @hard_soft WHERE [id] = @id">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="DropDownList1" DefaultValue="0" Name="id" 
                            PropertyName="SelectedValue" />
                    </SelectParameters>
                    <DeleteParameters>
                        <asp:Parameter Name="id" Type="Int32" />
                    </DeleteParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="name" Type="String" />
                        <asp:Parameter Name="imgeUrl" Type="String" />
                        <asp:Parameter Name="parent" Type="String" />
                        <asp:Parameter Name="hard_soft" Type="Int32" />
                        <asp:Parameter Name="id" Type="Int32" />
                    </UpdateParameters>
                    <InsertParameters>
                        <asp:Parameter Name="name" Type="String" />
                        <asp:Parameter Name="imgeUrl" Type="String" />
                        <asp:Parameter Name="parent" Type="String" />
                        <asp:Parameter Name="hard_soft" Type="Int32" />
                    </InsertParameters>
                </asp:SqlDataSource>
            </td>
            <td valign="top">
               
            <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" 
                DataKeyNames="id" DataSourceID="SqlDataSource_MProduct" ForeColor="#333333" 
                GridLines="None" Width="718px">
                <RowStyle BackColor="#E3EAEB" />
                <Columns>
                    <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" 
                        ReadOnly="True" SortExpression="id" />
                    <asp:BoundField DataField="name" HeaderText="name" SortExpression="name" >
                    <ControlStyle Width="150px" />
                    </asp:BoundField>
                    <asp:BoundField DataField="stock" HeaderText="stock" SortExpression="stock" />
                    <asp:BoundField DataField="price" HeaderText="price" SortExpression="price" />
                    <asp:BoundField DataField="Author" HeaderText="Author" 
                        SortExpression="Author" />
                    <asp:BoundField DataField="publishDate" HeaderText="publishDate" 
                        SortExpression="publishDate" />
                    <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" 
                        SelectText="Details" ShowSelectButton="True" />
                </Columns>
                <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
                <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
                <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                <EditRowStyle BackColor="#7C6F57" />
                <AlternatingRowStyle BackColor="White" />
            </asp:GridView>
            <asp:SqlDataSource ID="SqlDataSource_MProduct" runat="server" 
                ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                DeleteCommand="DELETE FROM [Product] WHERE [id] = @id" 
                InsertCommand="INSERT INTO [Product] ([name], [imageUrl], [description], [idCategory], [stock], [price], [Author], [publishDate]) VALUES (@name, @imageUrl, @description, @idCategory, @stock, @price, @Author, @publishDate)" 
                SelectCommand="SELECT * FROM [Product] WHERE [idCategory] = @idCategory" 
                UpdateCommand="UPDATE [Product] SET [name] = @name, [imageUrl] = @imageUrl, [description] = @description, [idCategory] = @idCategory, [stock] = @stock, [price] = @price, [Author] = @Author, [publishDate] = @publishDate WHERE [id] = @id">
                <SelectParameters>
                    <asp:ControlParameter ControlID="DropDownList1" DefaultValue="0" 
                        Name="idCategory" PropertyName="SelectedValue" />
                </SelectParameters>
                <DeleteParameters>
                    <asp:Parameter Name="id" Type="Int32" />
                </DeleteParameters>
                <UpdateParameters>
                    <asp:Parameter Name="name" Type="String" />
                    <asp:Parameter Name="imageUrl" Type="String" />
                    <asp:Parameter Name="description" Type="String" />
                    <asp:Parameter Name="idCategory" Type="Int32" />
                    <asp:Parameter Name="stock" Type="Int32" />
                    <asp:Parameter Name="price" Type="Double" />
                    <asp:Parameter Name="Author" Type="String" />
                    <asp:Parameter DbType="Date" Name="publishDate" />
                    <asp:Parameter Name="id" Type="Int32" />
                </UpdateParameters>
                <InsertParameters>
                    <asp:Parameter Name="name" Type="String" />
                    <asp:Parameter Name="imageUrl" Type="String" />
                    <asp:Parameter Name="description" Type="String" />
                    <asp:Parameter Name="idCategory" Type="Int32" />
                    <asp:Parameter Name="stock" Type="Int32" />
                    <asp:Parameter Name="price" Type="Double" />
                    <asp:Parameter Name="Author" Type="String" />
                    <asp:Parameter DbType="Date" Name="publishDate" />
                </InsertParameters>
            </asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td class="style1"></td>
            <td>
                
                <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
                    DataKeyNames="id" DataSourceID="SqlDataSourceDetailsProduct" Height="50px" 
                    Width="721px" CellPadding="4" ForeColor="#333333" GridLines="None">
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                    <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <Fields>
                        <asp:ImageField DataImageUrlField="imageUrl" HeaderText="Photo">
                            <ControlStyle Height="253px" Width="170px" />
                        </asp:ImageField>
                        <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" 
                            ReadOnly="True" SortExpression="id" />
                        <asp:BoundField DataField="name" HeaderText="name" SortExpression="name" />
                        <asp:BoundField DataField="description" HeaderText="description" 
                            SortExpression="description" />
                        <asp:BoundField DataField="idCategory" HeaderText="idCategory" 
                            SortExpression="idCategory" />
                        <asp:BoundField DataField="stock" HeaderText="stock" SortExpression="stock" />
                        <asp:BoundField DataField="price" HeaderText="price" SortExpression="price" />
                        <asp:BoundField DataField="Author" HeaderText="Author" 
                            SortExpression="Author" />
                        <asp:BoundField DataField="publishDate" HeaderText="publishDate" 
                            SortExpression="publishDate" />
                        <asp:CommandField ShowEditButton="True" />
                    </Fields>
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <EditRowStyle BackColor="#999999" />
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                </asp:DetailsView>
                <asp:SqlDataSource ID="SqlDataSourceDetailsProduct" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                    DeleteCommand="DELETE FROM [Product] WHERE [id] = @id" 
                    InsertCommand="INSERT INTO [Product] ([name], [imageUrl], [description], [idCategory], [stock], [price], [Author], [publishDate]) VALUES (@name, @imageUrl, @description, @idCategory, @stock, @price, @Author, @publishDate)" 
                    SelectCommand="SELECT * FROM [Product]  where [id] = @id" 
                    UpdateCommand="UPDATE [Product] SET [name] = @name, [imageUrl] = @imageUrl, [description] = @description, [idCategory] = @idCategory, [stock] = @stock, [price] = @price, [Author] = @Author, [publishDate] = @publishDate WHERE [id] = @id">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="GridView1" DefaultValue="0" Name="id" 
                            PropertyName="SelectedValue" />
                    </SelectParameters>
                    <DeleteParameters>
                        <asp:Parameter Name="id" Type="Int32" />
                    </DeleteParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="name" Type="String" />
                        <asp:Parameter Name="imageUrl" Type="String" />
                        <asp:Parameter Name="description" Type="String" />
                        <asp:Parameter Name="idCategory" Type="Int32" />
                        <asp:Parameter Name="stock" Type="Int32" />
                        <asp:Parameter Name="price" Type="Double" />
                        <asp:Parameter Name="Author" Type="String" />
                        <asp:Parameter DbType="Date" Name="publishDate" />
                        <asp:Parameter Name="id" Type="Int32" />
                    </UpdateParameters>
                    <InsertParameters>
                        <asp:Parameter Name="name" Type="String" />
                        <asp:Parameter Name="imageUrl" Type="String" />
                        <asp:Parameter Name="description" Type="String" />
                        <asp:Parameter Name="idCategory" Type="Int32" />
                        <asp:Parameter Name="stock" Type="Int32" />
                        <asp:Parameter Name="price" Type="Double" />
                        <asp:Parameter Name="Author" Type="String" />
                        <asp:Parameter DbType="Date" Name="publishDate" />
                    </InsertParameters>
                </asp:SqlDataSource>
                
                
                
                
            </td>
        </tr>
        <tr>
            <td class="style1"></td>
            <td>
                <asp:FormView ID="FormView2" runat="server" DataKeyNames="id" 
                DataSourceID="SqlDataSource_MProduct">
                <EditItemTemplate>
                    id:
                    <asp:Label ID="idLabel1" runat="server" Text='<%# Eval("id") %>' />
                    <br />
                    name:
                    <asp:TextBox ID="nameTextBox" runat="server" Text='<%# Bind("name") %>' />
                    <br />
                    imageUrl:
                    <asp:TextBox ID="imageUrlTextBox" runat="server" 
                        Text='<%# Bind("imageUrl") %>' />
                    <br />
                    description:
                    <asp:TextBox ID="descriptionTextBox" runat="server" 
                        Text='<%# Bind("description") %>' />
                    <br />
                    idCategory:
                    <asp:TextBox ID="idCategoryTextBox" runat="server" 
                        Text='<%# Bind("idCategory") %>' />
                    <br />
                    stock:
                    <asp:TextBox ID="stockTextBox" runat="server" Text='<%# Bind("stock") %>' />
                    <br />
                    price:
                    <asp:TextBox ID="priceTextBox" runat="server" Text='<%# Bind("price") %>' />
                    <br />
                    Author:
                    <asp:TextBox ID="AuthorTextBox" runat="server" Text='<%# Bind("Author") %>' />
                    <br />
                    publishDate:
                    <asp:TextBox ID="publishDateTextBox" runat="server" 
                        Text='<%# Bind("publishDate") %>' />
                    <br />
                    <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                        CommandName="Update" Text="Update" />
                    &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                        CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                </EditItemTemplate>
                <InsertItemTemplate>
                    Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:TextBox ID="nameTextBox" runat="server" Text='<%# Bind("name") %>' 
                        Width="242px" />
                    <br />
                    <br />
                    PhotoUrl:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:TextBox ID="imageUrlTextBox" runat="server" Height="22px" 
                        Text='<%# Bind("imageUrl") %>' Width="241px" />
                    <br />
                    <br />
                    Description:&nbsp;
                    <asp:TextBox ID="descriptionTextBox" runat="server" Height="124px" 
                        Text='<%# Bind("description") %>' TextMode="MultiLine" Width="247px" />
                    <br />
                    <br />
                    idCategory:&nbsp;&nbsp;
                    <asp:TextBox ID="idCategoryTextBox" runat="server" Height="22px" 
                        Text='<%# Bind("idCategory", "{0}") %>' Width="77px" />
                    <br />
                    <br />
                    Stock:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:TextBox ID="stockTextBox" runat="server" Height="22px" 
                        Text='<%# Bind("stock") %>' Width="77px" />
                    <br />
                    <br />
                    Price:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:TextBox ID="priceTextBox" runat="server" Text='<%# Bind("price") %>' />
                    <br />
                    <br />
                    Author:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:TextBox ID="AuthorTextBox" runat="server" Text='<%# Bind("Author") %>' />
                    <br />
                    <br />
                    Publish Date:
                    <asp:TextBox ID="publishDateTextBox" runat="server" 
                        Text='<%# Bind("publishDate") %>' />
                    <br />
                    <br />
                    <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                        CommandName="Insert" Text="Insert" />
                    &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                        CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="NewButton" runat="server" CssClass="prod_buy"  CausesValidation="False" 
                        CommandName="New" Text="New Product" />
                </ItemTemplate>
            </asp:FormView>
            </td>
        </tr>
    </table>
    </asp:Content>
